package com.hangzhou.welbeing.welbeinginstrument.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hangzhou.welbeing.welbeinginstrument.R;
import com.hangzhou.welbeing.welbeinginstrument.inteface.OnRecyclerViewItemClickListener;

/**
 * 时间 2017 年 09 月 12.
 * 作者 Administrator  刘传华
 * 公司 杭州惟君医疗科技有限公司
 * 包名 com.hangzhou.welbeing.pregnant.welbeing_pregnant.adapter
 * 工程名 welbeing_pregnant
 */
public class MessageAdapter extends  RecyclerView.Adapter<MessageAdapter.ViewHolder> implements View.OnClickListener {
    private  String[] arr = new String[]{"收到的赞","收到的评论","新增关注"};
    private OnRecyclerViewItemClickListener mOnItemClickListener = null;

    public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_recyclerview, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        view.setOnClickListener(this);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {
        holder.tv_direct_messages.setText(arr[position]);
    }

    @Override
    public int getItemCount() {
        return arr.length;
    }

    @Override
    public void onClick(View view) {
        if (mOnItemClickListener != null) {
            mOnItemClickListener.onItemClick(view);
        }
    }

    /**
     * 身体布局Holder
     */
    static class ViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_direct_messages;
        private ImageView iv_direct_messages;
        private RelativeLayout rl_direct_messages;

        public ViewHolder(View itemView) {
            super(itemView);
            tv_direct_messages = (TextView) itemView.findViewById(R.id.item_message_recyclerview_tv_direct_messages);
            iv_direct_messages = (ImageView) itemView.findViewById(R.id.item_message_recyclerview_iv_direct_messages);
            rl_direct_messages = (RelativeLayout) itemView.findViewById(R.id.item_message_recyclerview_rl_direct_messages);
        }
    }
}
